#include "configcontroller.h"
#include "datacollector.h"

ConfigController::ConfigController(ConfigData *data, ConfigView *view):
    m_configData(data),
    m_configView(view)
{
}
ConfigController::~ConfigController()
{
}

void ConfigController::setTranSetting(int tranType, const TTranSetting& setting)
{
    m_configData->setTranSetting(tranType, setting);
}

void ConfigController::addGen(std::string ip, int userCount)
{
    int genId = m_configData->addGen(ip, userCount);
	DataCollector *dc = DataCollector::GetInstance();
	TGenConfig config;
	config.ip = ip;
	config.userCount = userCount;
	config.isOn = false;

	dc->AddAgent(genId, config);
	m_configView->addGen(genId);
}

void ConfigController::delGen(int genId)
{
    m_configData->delGen(genId);
}

void ConfigController::setGenConfig(int genId, const TGenConfig& config)
{
    m_configData->setGenConfig(genId, config);
}

TTranSetting ConfigController::getTranSetting(int tranType)
{
    return m_configData->getTranSetting(tranType);
}

TGenConfig ConfigController::getGenConfig(int genId)
{
    return m_configData->getGenConfig(genId);
}

void ConfigController::setDuration(int duration)
{
	m_configData->setDuration(duration);
}

int ConfigController::getDuration()
{
	return m_configData->getDuration();
}

void ConfigController::setIncUser(int user)
{
	m_configData->setIncUser(user);
}

int ConfigController::getIncUser()
{
	return m_configData->getIncUser();
}

void ConfigController::setIncTime(int sec)
{
	m_configData->setIncTime(sec);
}

int ConfigController::getIncTime()
{
	return m_configData->getIncTime();
}

void ConfigController::setUpdateRate(int rate)
{
	m_configData->setUpdateRate(rate);
}

int ConfigController::getUpdateRate()
{
	return m_configData->getUpdateRate();
}

void ConfigController::setServerIP(std::string ip)
{
	m_configData->setServerIP(ip);
	DataCollector *dc = DataCollector::GetInstance();
	dc->SetServerIP(ip);
}

std::string ConfigController::getServerIP()
{
	return m_configData->getServerIP();
}
